package com.dao.impl;

import com.Bean.Fddate;
import com.Bean.RoomList;

import com.dao.StatisticsDao;
import com.util.JdbcUtil;

import java.sql.SQLException;
import java.util.List;

public class StatisticsDaolmpl  implements StatisticsDao {
    @Override
    public int insert(RoomList roomList) throws SQLException {
        return 0;
    }

    @Override
    public List<RoomList> queryData(RoomList roomList) throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select intime,sum(lsum) lsum,sum(lroomprice) lroomprice,sum(lotherprice) lotherprice,sum(lillegal) lillegal from room_list GROUP BY intime" ;
//                " HAVING intime BETWEEN "+roomList.getIntime()+"and"+ roomList.getOuttime();
        sql+=" ORDER BY intime";
        return JdbcUtil.queryData(sql,RoomList.class);
    }

    @Override
    public int update(RoomList roomList) throws SQLException {
        return 0;
    }

    @Override
    public int deleteById(Object id) throws SQLException {
        return 0;
    }



    public List<RoomList> queryDataone(RoomList roomList, Fddate fddate) throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select intime,sum(lsum) lsum,sum(lroomprice) lroomprice,sum(lotherprice) lotherprice,sum(lillegal) lillegal from room_list GROUP BY intime" ;

        System.out.println(fddate.getLastDay());

        if(fddate.getLastDay()!=null){
            sql+=  " HAVING intime BETWEEN  '"+fddate.getFristDay()+"'  and  '"+ fddate.getLastDay()+"'";
            System.out.println(sql);
        }
        sql+=" ORDER BY intime";
        return JdbcUtil.queryData(sql,RoomList.class);
    }

}
